package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.item.client.ItemFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

/**
 * @author: 李旭
 * @create: 2021-08-30 11:06
 **/
@Controller
public class ItemController {


    @Autowired
    private ItemFeignClient itemFeignClient;
    //进入商品详情页面
    @GetMapping("/{skuId}.html")
    public String getItem(@PathVariable Long skuId, Model model){

        //1:查询DB数据
        Map map = itemFeignClient.getItem(skuId);
        model.addAllAttributes(map);//K : V
        return "item/index";

    }

}
